/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jwavefront.view;

import java.io.File;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import jwavefront.JWavefrontModel;

/**
 *
 * @author Felipe
 */
public class Objeto3D {
    private float x, y, z;
    private JWavefrontModel modelo;
    private GLAutoDrawable glad;
    
    public Objeto3D(String filename, float x, float y, float z, GLAutoDrawable glad) throws IOException {
        this.x = x;
        this.y = y;
        this.z = z;
        modelo = new JWavefrontModel(new File(filename));
        
        modelo.unitize();
        modelo.facetNormals();
        modelo.vertexNormals(90);
        modelo.dump(true);        
        this.glad = glad;        
        modelo.compile(glad, JWavefrontModel.WF_MATERIAL | JWavefrontModel.WF_TEXTURE | JWavefrontModel.WF_SMOOTH);
        
    }
    
    public void draw(GL gl){
        gl.glRotatef(-90f, 0, 1, 0);
        gl.glTranslatef(-0.05f, 0, 8);
        modelo.draw(glad);
    }
}
